#pragma once
#include <string.h>
#include <iostream>
using namespace std;
#include <assert.h>

namespace bit
{

	class string
	{
	public:
		typedef char* iterator;
		string(const char* s)
		{
			size_t size = strlen(s);
			_start = new char[size + 1];
			strcpy(_start, s);
			_finish = _start+size;
			_end_of_sortage = _finish+1;
		}

		string(const string& s)
		{
			_start = new char[s.capacity()+1];
			strcpy(_start, s._start);
			_finish = _start + s.size();
			_end_of_sortage = _start + s.capacity();
		}

		~string()
		{
			delete[] _start;
			_start = nullptr;
			_finish = nullptr;
			_end_of_sortage = nullptr;
		}
		iterator begin();
		iterator end();


		char* c_str();
		size_t size()const;
		size_t capacity()const;
		void reserve(size_t size = 0);

		string& operator=(const char* s);
		string& operator=(const string& s);
		char& operator[](size_t pos);

		string& operator+=(const char* s);
		string& append(const char* s);

		char push_back();

		string& assign(char* s);
		string& insert(size_t pos, const char* s);

		void swap(string& s);


		string& erase(size_t pos = 0,size_t len = npos);
	private:
		char* _start = nullptr;
		char* _finish = nullptr;
		char* _end_of_sortage = nullptr;
		static const size_t npos = -1;
	};

};